package net.tensor.tensorprovider.zhujie;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class Demo {

    public static void main(String[] args) throws Exception {

        Person person = new Person();
        person.setName("hello");
        Class clazz = person.getClass();
        Field field = clazz.getDeclaredField("name");
        field.setAccessible(true);
        Annotation[] annotations = field.getAnnotations();
        for (Annotation annotation : annotations) {
            if (annotation.annotationType().equals(NotNullAnnotation.class)) {
                if (field.get(person) == null) {
                    System.out.println("name不能为空");
                }else {
                    System.out.println(field.get(person));
                }
            }
        }
    }

}